package com.iams.manage.controller;

import java.util.List;

import com.iams.manage.domain.workflow.dto.IdentificationRecordDTO;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.iams.common.annotation.Log;
import com.iams.common.core.controller.BaseController;
import com.iams.common.core.domain.AjaxResult;
import com.iams.common.enums.BusinessType;
import com.iams.manage.domain.workflow.IdentificationRecord;
import com.iams.manage.service.IIdentificationRecordService;
import com.iams.common.utils.poi.ExcelUtil;
import com.iams.common.core.page.TableDataInfo;

/**
 * 鉴定审批Controller
 * 
 * @author LiuTao
 * @date 2025-04-04
 */
@RestController
@RequestMapping("/manage/identificationApproval")
public class IdentificationApprovalController extends BaseController
{
    @Autowired
    private IIdentificationRecordService identificationRecordService;

    /**
     * 查询鉴定审批列表
     */
    @PreAuthorize("@ss.hasPermi('manage:identificationApproval:list')")
    @GetMapping("/list")
    public TableDataInfo list(IdentificationRecord identificationRecord)
    {
        startPage();
        List<IdentificationRecordDTO> list = identificationRecordService.selectIdentificationRecordList(identificationRecord);
        return getDataTable(list);
    }

    /**
     * 导出鉴定审批列表
     */
    @PreAuthorize("@ss.hasPermi('manage:identificationApproval:export')")
    @Log(title = "鉴定审批", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, IdentificationRecord identificationRecord)
    {
        List<IdentificationRecordDTO> list = identificationRecordService.selectIdentificationRecordList(identificationRecord);
        ExcelUtil<IdentificationRecordDTO> util = new ExcelUtil<IdentificationRecordDTO>(IdentificationRecordDTO.class);
        util.exportExcel(response, list, "鉴定审批数据");
    }

    /**
     * 获取鉴定审批详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:identificationApproval:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(identificationRecordService.selectIdentificationRecordById(id));
    }

    /**
     * 新增鉴定审批
     */
    @PreAuthorize("@ss.hasPermi('manage:identificationApproval:add')")
    @Log(title = "鉴定审批", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody @Valid IdentificationRecordDTO identificationRecordDTO)
    {
        return toAjax(identificationRecordService.insertIdentificationRecord(identificationRecordDTO));
    }

    /**
     * 修改鉴定审批
     */
    @PreAuthorize("@ss.hasPermi('manage:identificationApproval:edit')")
    @Log(title = "鉴定审批", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody @Valid IdentificationRecordDTO identificationRecordDTO)
    {
        return toAjax(identificationRecordService.updateIdentificationRecord(identificationRecordDTO));
    }

    /**
     * 删除鉴定审批
     */
    @PreAuthorize("@ss.hasPermi('manage:identificationApproval:remove')")
    @Log(title = "鉴定审批", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(identificationRecordService.deleteIdentificationRecordByIds(ids));
    }
}
